<template>

  <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="会计年度">
      <el-select v-model="formInline.blnisinactive" placeholder="请选择" style="width:90px" @change="blnisinClick">
        <el-option v-for="item in list" :key="item.intyear" :value="item.lngaccountyearid" :label="item.intyear" />
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
// import { product } from '@/api/department-parameter'
import { getYearListData, delCalendar } from '@/api/system/global-setting/calendar'
import { mapGetters } from 'vuex'
export default {
  name: 'CalendarSettingSearch',
  data() {
    return {
      formInline: {
        blnisinactive: '',
        names: ''
      },
      list: [],
      employeeTypeList: [],
      productList: []
    }
  },
  computed: {
    ...mapGetters(['staffTypeList']),
    whereArr() {
      return this.formInline.blnisinactive
    }
  },
  mounted() {
    this.getYearList()
  },
  methods: {
    getYearList() {
      getYearListData().then(res => {
        if (res.code === 20000) {
          this.list = res.data
          if (this.list.length > 0) {
            this.formInline.blnisinactive = this.list[0].lngaccountyearid
            this.formInline.names = this.list[0].intyear
          } else {
            this.list = []
            this.formInline.blnisinactive = ''
            this.formInline.names = ''
          }
          this.$parent.$parent.$refs['TableArea'].queryListByPage()
        } else {
          this.list = []
        }
      })
    },
    blnisinClick(e) {
      this.list.map((item) => {
        if (item.lngaccountyearid === e) {
          this.formInline.names = item.intyear
        }
      })
    },
    onSubmit() {
      this.$parent.$parent.$refs['TableArea'].queryListByPage()
      this.$emit('search', this.formInline)
    },
    onDel() {
      this.$confirm('确认要删除' + this.formInline.names + '该年的数据吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delCalendar(this.formInline.blnisinactive).then(res => {
          if (res.code === 20000) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getYearList()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

